package com.ww.yaodao.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;

@SpringBootConfiguration
public class MPConfig {
    @Bean
    public MybatisPlusInterceptor createMybatisPlusInterceptor() {
        //创建一个拦截器栈
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();

        //创建一个分页拦截器对象
        PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();

        //给分页拦截器对象设置相关属性
        //设置数据库类型
        //paginationInnerInterceptor.setDbType(DbType.MYSQL);

        //往拦截器栈添加分页拦截器
        mybatisPlusInterceptor.addInnerInterceptor(paginationInnerInterceptor);
        return mybatisPlusInterceptor;
    }

}
